#include <bits/stdc++.h>
using namespace std;
void solve() {
  string l;
  cin >> l;
  cout << (l[0] + l[1] + l[2] == l[3] + l[4] + l[5] ? "YES\n" : "NO\n");
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) solve();
}
